﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Decoration.Models.Models
{
    public class OrderDetail
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        /// <summary>
        /// 订单id
        /// </summary>
        [ForeignKey(nameof(OrderId))]
        public int OrderId { get; set; }

        /// <summary>
        /// 产品
        /// </summary>
        [ForeignKey(nameof(ProductId))]
        public int ProductId { get; set; }

        [MaxLength(50)]
        public string ProductName { get; set; } = null!;

        /// <summary>
        /// 单价
        /// </summary>
        [Column(TypeName = "decimal(18,2)")]
        public decimal Price { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public int Count { get; set; }

        /// <summary>
        /// 小计
        /// </summary>
        [Column(TypeName = "decimal(18,2)")]
        public decimal Total { get; set; }

        public DateTime CreateTime { get; set; } = DateTime.Now;

        public int Status { get; set; } = 1;

        public virtual OrderInfo Order { get; set; } = new OrderInfo();

        public virtual ProductInfo? Product { get; set; } = null;
    }
}
